package main.java.FSMDE.validation.rules;

import java.util.ArrayList;
import java.util.List;

import main.java.FSMDE.models.ComplexComponent;
import main.java.FSMDE.models.Component;
import main.java.FSMDE.models.Diagram;
import main.java.FSMDE.models.Interface;
import main.java.FSMDE.validation.IValidationEntry;


public class ComplexComponentShouldHaveComponentsValidator implements
		IRulesValidator {

	@Override
	public Iterable<IValidationEntry> validate(Diagram diagram) {
		List<IValidationEntry> entries = new ArrayList<IValidationEntry>();
		
		for (Interface inface : diagram.getInterfaces()) {
			for(Component component : inface.getComponents()){
				if(component.isComplex()){
					if( ((ComplexComponent) component).getComponents().count() == 0) entries.add(new ComplexComponentShouldHaveComponentsValidationEntry(diagram, inface, component) );
				}
			}
		}
		return entries;
	}

}
